feat(java): proxy sessions with identity dedup and cleanup#369
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors ChangesProxySession feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant ProxySession
participant Proxies
participant ProxyHandler
Caller->>ProxySession: reconstruct(ref)
ProxySession->>ProxySession: ensureOpen()
ProxySession->>Proxies: verify(ref, expectedPurpose)
Proxies->>ProxyHandler: handlerFor(ref.handler())
ProxyHandler-->>Proxies: reconstruct(ref.reference())
Proxies-->>ProxySession: value
ProxySession->>ProxySession: memoize value, push cleanup action
ProxySession-->>Caller: value
Caller->>ProxySession: close()
ProxySession->>ProxyHandler: cleanup(value) [LIFO order]
ProxySession->>ProxySession: clear memoization state
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdks/java/src/main/java/org/byteveda/taskito/proxies/ProxySession.java`:
- Around line 115-132: ProxySession.close() only catches RuntimeException during
cleanup, so an Error from cleanup.run() can abort the teardown loop and leave
remaining cleanups permanently undrained because closed is already true. Update
the close() cleanup loop in ProxySession to catch Throwable instead of
RuntimeException, keep logging the failure with LOG.log(Level.WARNING, ...), and
continue draining cleanups so every pending resource is torn down in LIFO order
even if one cleanup fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 99052d4c-8210-44b2-8aef-2986247144cf
📒 Files selected for processing (4)
sdks/java/src/main/java/org/byteveda/taskito/proxies/Proxies.javasdks/java/src/main/java/org/byteveda/taskito/proxies/ProxyHandler.javasdks/java/src/main/java/org/byteveda/taskito/proxies/ProxySession.javasdks/java/src/test/java/org/byteveda/taskito/ProxyTest.java
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
Adds a unit-of-work session layer to the proxy system, giving it identity dedup and a cleanup lifecycle — previously N refs to the same resource meant N handler calls, N instances, and no way to release anything.
ProxySession(AutoCloseable, thread-confined likeTaskScope), created viaproxies.session():deconstructmemoizes by (instance identity, purpose) — deconstructing the same object again returns the same signed ref without invoking the handler twice. Purpose is part of the key so a ref bound to one purpose is never handed out for another; the first call's TTL wins per key.reconstruct/resolvememoize by the ref's signature (the HMAC covers handler, canonical reference, expiry, and purpose, so equal signatures mean equal content) — every ref to the same resource resolves to one shared instance, reconstructed once. Signature, expiry, and purpose are re-verified on every call, memo hits included, so a ref that expires mid-session stops resolving.close()runs the newProxyHandler.cleanup(value)hook once per unique reconstructed instance, LIFO, with per-entry error isolation; idempotent; use-after-close throws.ProxyHandlergainsdefault void cleanup(T value) {}— binary-compatible with every existing handler; only session-reconstructed instances participate (directProxies.reconstructstays lifecycle-free, documented).Proxiesrefactor: verification and handler lookup extracted into package-privateverify/handlerFor(error precedence unchanged); public API otherwise untouched and still stateless.Tests
7 new
ProxyTestcases: same-instance deconstruct dedup (handler called once), purposes kept distinct, reconstruct memo (same instance, handler called once), cleanup-once LIFO order + idempotent close, session isolation, re-verify on memo hit with a short TTL, use-after-close rejection. 19/19 green; full./gradlew buildgreen.Summary by CodeRabbit
New Features
Bug Fixes